#ifndef CPU_HPP
#define CPU_HPP

#include <QObject>

#include "command.hpp"
#include "watchdog.hpp"
#include "datamemoryorganisation.hpp"
#include "stackmanagement.hpp"

class CPU : public QObject
{
Q_OBJECT
public:

    /**
    * @brief Creates a new instance
    *
    * @fn CPU
    * @param parent
    */
    explicit CPU(DataMemoryOrganisation *dmo, StackManagement *sm, Watchdog *watchdog, QObject *parent = 0);

    /**
    * @brief
    *
    * @fn executeCommand
    * @param command
    */
    int executeCommand(Command *command, int programCounter);

    void reset();

    /**
    * @brief Returns the Runtime as String
    *
    * @fn getRuntime
    * @return int
    */
    QString getRuntimeAsString() const;

private:

    Watchdog *watchdog;
    DataMemoryOrganisation *dataMemoryOrganisation;
    StackManagement *stackManagement;
    int runtime;

    void setCarryFlag(int newValue);

    void setDigitCarryFlag(int oldValue, int newValue);

    void setZeroFlag(int newValue);

signals:

public slots:

};

#endif // CPU_HPP
